import http from '../utils/http'
// 获取孩子成员列表
export const getMemberList = (data:{userId:number})=>{
  return http({
    method:"GET",
    url:"/user/student/listByUserId",
    data
  })
}
// 获取校区列表
export const getSchoolList = ()=>{
  return http({
    method:"GET",
    url:"/user/school/list",
  })
}
// 获取学生列表
export const getRemainStudent = (data:{
  serialId:number,
  stuId?:number
})=>{
  return http({
    method:"GET",
    url:"/user/course/purchasableStudent",
    data
  })
}
// 获取签到二维码
export const getSignCode = (data:{
  stuId:number,
  userId?:number
})=>{
  return http({
    method:"GET",
    url:"/user/parent/signCode",
    data
  })
}
// 获取签到历史记录
export const getSignHistoryList = (data:{
  year:number,
  month:number,
  pageSize?:number,
  pageNum?:number,
  stuId?:number,
  userId?:number
})=>{
  return http({
    method:"GET",
    url:"/user/parent/signHistory",
    data
  })
}
// 查询课程表
export const getClassList = (data:{
  year?:number,
  month?:number,
  stuId?:number
})=>{
  const isTeacher = getApp().getUserType() === "01"
  return http({
    method:"GET",
    url:`/${isTeacher ? 'teacher' : 'user'}/lesson/list`,
    data
  })
}
// 根据日期范围查询课程表
export const getClassListForRange=(data:{
  endDate?:string,
  startDate?:string,
  stuId?:number
})=>{
  return http({
    method:"GET",
    url:"/user/lesson/listByDate",
    data
  })
}
// 添加修改学员
export const addStudent = (data:{
  avatar?: string,
  birthday: string,
  familyRel: string,
  idCard: string,
  nickName: string,
  parentId: number,
  phonenumber: string,
  remark?: string,
  schoolId?: string,
  sex: string,
  userName: string
},type:boolean)=>{ //type为true时，添加学员；type为false时，修改学员信息
  return http({
    method:"POST",
    url:`/user/student/${type ? 'add' : 'edit'}`,
    data
  })
}
// 获取学员信息接口
export const userInfoList = (data:{
  userId:number
})=>{
  return http({
    method:"GET",
    url:"/user/student/listByParentId",
    data
  })
}
